import java.util.concurrent.SynchronousQueue;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread thread1 = new Thread(() -> {
            synchronized (locker) {
                System.out.println("thread1调用wait(), 阻塞等待");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("thread1被唤醒");
            }
        });
        Thread thread2 = new Thread(() -> {
            synchronized (locker) {
                System.out.println("thread2调用wait(), 阻塞等待");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("thread2被唤醒");
            }
        });
        Thread thread3 = new Thread(() -> {
            synchronized (locker) {
                System.out.println("thread3调用wait(), 阻塞等待");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("thread3被唤醒");
            }
        });

        Thread thread4 = new Thread(() -> {
            try {
                Thread.sleep(3);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker) {
                locker.notifyAll();
                System.out.println("thread4调用notifyAll()");
            }
        });

        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();

    }
}